package com.xunge.mapper;

import com.xunge.pojo.ExamRecord;
import com.xunge.pojo.ExamRecordQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ExamRecordMapper {

    /**
     * 分页查询考试记录信息
     */
    List<ExamRecord> list(ExamRecordQueryParam examRecordQueryParam);

    /**
     * 新增考试记录
     */
    @Insert("insert into exam_record(exam_id, student_id, score, status, remark, create_time, update_time) " +
            "values(#{examId}, #{studentId}, #{score}, #{status}, #{remark}, now(), now())")
    void insert(ExamRecord examRecord);

    /**
     * 根据ID查询考试记录
     */
    @Select("select * from exam_record where id = #{id}")
    ExamRecord getById(Integer id);

    /**
     * 根据ID修改考试记录
     */
    void update(ExamRecord examRecord);

    /**
     * 根据ID删除考试记录
     */
    @Delete("delete from exam_record where id = #{id}")
    void deleteById(Integer id);

    /**
     * 批量删除考试记录
     */
    void deleteByIds(List<Integer> ids);

    /**
     * 根据考试ID查询记录
     */
    @Select("select * from exam_record where exam_id = #{examId}")
    List<ExamRecord> getByExamId(Integer examId);

    /**
     * 根据学生ID查询记录
     */
    @Select("select * from exam_record where student_id = #{studentId}")
    List<ExamRecord> getByStudentId(Integer studentId);

    /**
     * 根据考试ID和学生ID查询记录
     */
    @Select("select * from exam_record where exam_id = #{examId} and student_id = #{studentId}")
    ExamRecord getByExamIdAndStudentId(Integer examId, Integer studentId);
} 